package zhaomh.zlogin;

import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import zhaomh.zlogin.Commands.LoginCommand;
import zhaomh.zlogin.Commands.RegisterCommand;
import zhaomh.zlogin.Listeners.Listeners;

import java.util.Objects;

public final class Zlogin extends JavaPlugin {
    public void regCommands() {

        /* 添加命令别名代码
        List<String> list = Data.config.getStringList("commands.login");
        if (list != null) {
            for (String string : list) {
                if (!"login".equals(string))
                     Objects.requireNonNull(getCommand(string)).setExecutor(new LoginCommand());
            }
        }
        list = Data.config.getStringList("commands.register");
        if (list != null) {
            for (String string : list) {
                if (!"register".equals(string))
                    Objects.requireNonNull(getCommand(string)).setExecutor(new RegisterCommand());
            }
        }*/

        Objects.requireNonNull(getCommand("login")).setExecutor(new LoginCommand());
        Objects.requireNonNull(getCommand("register")).setExecutor(new RegisterCommand());
    }
    public void regListener() {
        Bukkit.getPluginManager().registerEvents(new Listeners(),this);

    }
    @Override
    public void onEnable() {
        saveDefaultConfig();
        Data.initialize();
        Language.initialize();
        PlayerData.initialize();
        Tools.initialize("&d[Zlogin]&r");
        regCommands();
        regListener();

    }

    @Override
    public void onDisable() {
        // Plugin shutdown logic
    }
}
